home *** CD-ROM | disk | FTP | other *** search
- Path: andrew.cmu.edu!dw3u+
- From: "Daniel C. Wang" <dw3u+@andrew.cmu.edu>
- Newsgroups: comp.lang.c,comp.lang.misc
- Subject: Re: GOTO controversy
- Date: Wed, 10 Apr 1996 15:26:16 -0400
- Organization: Senior, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
- Message-ID: <0lP0hM200YUg06zF40@andrew.cmu.edu>
- References: <314FB5F5.259B@simi.is> <3151B47F.70FD@connix.com>
- <4jc1qa$lvv@news.microsoft.com>
- NNTP-Posting-Host: po9.andrew.cmu.edu
- In-Reply-To: <4jc1qa$lvv@news.microsoft.com>
-
-
-
- a-cnadc@microsoft.com (Dann Corbit) writes:
- > In article <3151B47F.70FD@connix.com>, shawley@connix.com says...
- > >
- > >What to you think? Loops without using loops?
- > >
- > >a loop:
- > >
- > >for(i=0;i<10;i++)
- > >{
- > > stuff
- > >}
- > >
- > >Looping with out a loop
- > >
- > >no_loop(0,10);
- > >
- > >no_loop(int start, int end)
- > >{
- > > if(start != end) {
- > > stuff
- > > no_loop(start+1,end);
- > > }
- > >}
- > >
- > >I haven't tested this but you get the idea.
- > Yes, recursion can be used to loop "without a loop".
- > There is no practical advantage to this method.
- > The recursive version has 10 function calls to add
- > to its overhead.
-
- You obviously haven't attempted to write a data flow analysis for a compiler
- of a functional language vs. a language with explicate loops.
-
- P.S. in a functional world in-lining a recursive function == loop unrolling
- for free.
-
- Course just because it makes the compiler writers life easier its not
- necessarily a plus for the programmer, but there is definetly a practical
- advantage of some sort.
-
-